#version 110

varying vec3 LightIntensity;
varying vec2 TexCoord;

uniform vec4 LightPosition; // Light position in eye coords.
uniform vec3 Kd; // Diffuse reflectivity
uniform vec3 Ld; // Light source intensity

uniform mat4 ModelMatrix;
uniform mat4 ViewMatrix;
uniform mat3 NormalMatrix;
uniform mat4 ProjectionMatrix;
uniform float TIEMPO;

void main()
{
	// Ondas 
		

	// Convert normal and position to eye coords
	vec3 tnorm = normalize( NormalMatrix * gl_Normal);
	vec4 eyeCoords = ViewMatrix * ModelMatrix * gl_Vertex;
	vec3 s = normalize(vec3(LightPosition - eyeCoords));
	
	// Pasamos las coordenadas de texturas a los FShaders
	TexCoord = gl_MultiTexCoord0.xy;

	// The diffuse shading equation
	LightIntensity =  Ld * Kd * max( dot( s, tnorm ), 0.0 );
	
	vec4 v = vec4(gl_Vertex);
	
	//v.x = v.x + 0.25 *  cos(0.05*TIEMPO) * sin(0.75*v.z);
	//v.y = v.y + 0.25 *  cos(0.05*TIEMPO) * cos(0.75 *v.z);
	v.y = v.y + 0.25 *  cos(0.75 *v.z+ TIEMPO * (-0.1));
	v.x = v.x + 0.25 *  cos(0.75 *v.x+ TIEMPO * (-0.1));
	//v.z = v.z + 0.5 *  cos(0.5*TIEMPO) * sin(0.75*v.z);
		//v.x = v.x ;
		//v.y = v.y;
		//v.z = v.z + 0.57 * cos(0.25*TIEMPO) * sin(0.5*v.z);
	// Convert position to clip coordinates and pass along
	gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * v;
}

